package com.changgou.search.controller;

import com.changgou.search.service.SkuEsService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ：hushengjin
 */

@RestController
@CrossOrigin
@RequestMapping("/search")
public class SkuController {

    @Autowired
    private SkuEsService skuEsService;

    @GetMapping("/import")
    public Result search() {
        skuEsService.importSku();
        return new Result(true, StatusCode.OK, "导入成功");
    }

    /**
     * 搜索
     *
     * @param searchMap
     * @return
     */
    @GetMapping
    public Map search(@RequestParam(required = false) Map<String, String> searchMap) {
        return skuEsService.search(searchMap);
    }

}
